#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = (a); i <= (int)(b); ++i)
const int MOD = 1e9 + 7;
typedef vector<ll> vl;
typedef vector<vl> vvl;
struct Mat {
  int r, c;
  vvl f;
  Mat(int r, int c = 1) : r(r), c(c), f(r + 1, vl(c + 1)){};
  Mat operator*(const Mat &b) {
    assert(c == b.r);
    Mat m(r, b.c);
    rep(i, 1, r) rep(j, 1, b.c)
        rep(k, 1, c)(m.f[i][j] += f[i][k] * b.f[k][j] % MOD) %= MOD;
    return m;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n, k;
  cin >> n >> k;
  --k;
  vl A(n + 1);
  Mat G(n, n), f(n);
  rep(i, 1, n) cin >> A[i], f.f[i][1] = 1;
  rep(i, 1, n) rep(j, 1, n) {
    G.f[i][j] = __builtin_popcountll(A[i] ^ A[j]) % 3 == 0;
  }
  for (ll i = 0; (1LL << i) <= k; ++i, G = G * G) {
    if ((1LL << i) & k) f = G * f;
  }
  ll ans = 0;
  rep(i, 1, n)(ans += f.f[i][1]) %= MOD;
  cout << ans << endl;
}
